<template>
    <div class="header">
        <div class="header-content">
            <van-icon name="arrow-left" size="1.125rem" class="header-back" @click="back"/>
            <div class="header-name">
                <slot name="headerName"></slot>
            </div>
            <div class="header-other">
                <slot name="headerOtherIcon"></slot>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    methods: {
        back() {
            //返回打点
            $sensorsTrack('financing_videoZoneFunctionClick', {
                page_name: '首页',
                function_name:'返回'
            });
            const curUrl = window.location.href;
            if (curUrl.includes('Home')) {
                this.clickClose();
            } else {
                window.history.go(-1)
            }
        },
        clickClose() {
            if (window.terminal.isZxjtIos) {
                window.webkit.messageHandlers.closeCurrentWindow.postMessage("");
            } else if (window.terminal.isZxjtAndroid) {
                KDS_Native.closeCurrentWindow();
            } else {
                window.history.go(-1)
            }
        },
    }
}
</script>

<style scoped lang="less">
.header {
    width: 100%;
    height: 88px;
    background-color: #FFFFFF;
    .header-content{
        width: 100%;
        height: 100%;
        position: relative;
        .header-back,
        .header-name,
        .header-other {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
        }
        .header-back{
            margin-left: 26px;
        }
        .header-name{
            color:#101419;
            font-size: 34px;
            font-weight: 600;
            left: 50%;
            transform: translate(-50%,-50%);
        }
        .header-other{
            right: 0;
        }
    }
    
}
</style>